import React, { Component } from 'react'
import MainBanner from './MainBanner';
import axios from "axios"
import MainProductList from './MainProductList';
 class Main extends Component {
  constructor() {
    super()
    this.state = {
      banners:[],
      productList:[]
    }
  }
  componentDidMount(){
    axios.get("http://123.207.32.32:8000/home/multidata").then(res=>{
      console.log(res)
      const banners = res.data.data.banner.list 
      const recommend = res.data.data.recommend.list
      this.setState({
        banners,
        productList:recommend
      })
    })
  }
  render() {
    const { banners, productList } = this.state
    return (
      <div className='main'>
        <div>main</div>
        <MainBanner ></MainBanner>
        <MainBanner banners={banners} title="轮播图"></MainBanner>
        <MainProductList productList={productList}></MainProductList>
      </div>
    )
  }
}

export default Main